<?php
namespace Admin\Controller;
use Think\Controller;
class OrderController extends CommonController {
    //订单列表
    public function index() {
        $order = D('Goodsorder');
        $where['o.status'] = 0;
        $keywords = I('keywords', '');
        if($keywords) {
            $where['o.order_sn|r.tel'] = ['like', '%'.$keywords.'%'];
        }

        $data = $order->where($where)->getOrderList($where);

        $this->assign('count', $data['count']);
        $this->assign('list', $data['list']);
        $this->assign('p', I('p', 1, 'intval'));
        $this->display();
    }

    //发货
    public function sendGoods() {
        $id = I('id', 0, 'intval');
        $type = I('type', 0, 'intval');

        if(M('Goodsorder')->where(['id'=>$id])->setField('send_goods', $type) !== false) {
            $this->ajaxReturn(V(1, '保存成功'));
        } else {
            $this->ajaxReturn(V(0, '保存失败'));
        }
    }
}